package kr.hkit.powerjava.chapter13;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class WindowBulider_FrameTest extends JFrame {

	private JPanel contentPane;
	private JTextField jtf01;
	private JTextField jtf02;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					WindowBulider_FrameTest frame = new WindowBulider_FrameTest();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public WindowBulider_FrameTest() {
		Toolkit tool = Toolkit.getDefaultToolkit();
		Dimension screenSize = tool.getScreenSize();
		
		Dimension frameSize = new Dimension(300,200);
		
		int x = (int) (screenSize.getWidth()/2 - frameSize.getWidth()/2);
		int y = (int) (screenSize.getHeight()/2 - frameSize.getWidth()/2);
		setTitle("윈도우빌더-테스트");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//		setBounds(100, 100, 450, 300); //x, y , width, height 
		
		setBounds(x, y, (int) frameSize.getWidth(), (int) frameSize.getHeight());	
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); //가운데 정렬 위 아래 컴포넌트 간격.. Horrizon/Vertical
		
		JPanel mainPanel = new JPanel();
		contentPane.add(mainPanel);
		
		JButton btn01 = new JButton("버튼1");
		btn01.setEnabled(false);
		mainPanel.add(btn01);
		
		JButton btn02 = new JButton("버튼2");
		mainPanel.add(btn02);
		
		JPanel panel = new JPanel();
		contentPane.add(panel);
		
		jtf01 = new JTextField();
		panel.add(jtf01);
		jtf01.setColumns(10);
		
		jtf02 = new JTextField();
		jtf02.setHorizontalAlignment(SwingConstants.CENTER);
		jtf02.setText("test");
		jtf02.setEditable(false);
		panel.add(jtf02);
		jtf02.setColumns(10);
		pack();
	}

}
